OpenRoads Designer CONNECT Edition SDK Help

Developing with the ClrSDK

What is CLR?

CLR stands for Common Language Runtime. It is a virtual machine that executes managed code. Managed code is written in a language that is supported by the CLR such as C#, Visual Basic .NET, or C++/CLI.

In C++, the CLR can be used to write code that can interoperate with other .NET languages. This means that C++ code can call C# code, and vice versa.

About ClrSDK project

The ClrSDK project is an example of Managed C++ SDK. This example demonstrates creation of customize annotations including the creation of an annotation definition, it's property, method of drawing annotation and annotation registration method.

Debugging and Using the ClrSDK Project

  • Build the project

Open the SDK developer shell in administrator mode and use below command to build the project.

bmake ClrSDKExample/ClrSDKExample.mke

  • Enable debugging

Now to enable debugging and to hit the breakpoints in the code below steps are necessary.

Run below command in SDK developer shell

cd ClrSDKExample

Now run below command

bmake -a -ddebug

Run command devenv to start the visual studio.

  • Open the executable file for your installed version of Open Roads Designer

Inside Visual Studio, you can open an executable file just like you can open a solution file - using the dialog under File > Open > Project/Solution. From there, make sure that the file type you're browsing for is All Project Files:

Now, navigate to your installation of ORD. For example, most users have it installed under their program files:

C:\Program Files\Bentley\OpenRoads Designer 2023.00\OpenRoadsDesigner\

In that folder is the OpenRoadsDesigner.exe file, which you should be able to select to open in Visual Studio.

  • Open the files compiled for your project

When you compiled your project in the SDK Developer Shell, the compiler took the source files specified in your .mke file and compiled them into objects, putting them inside of your installation of ORD.

In this case, the main file here is ClrSDKExample.cpp which contains an entry point for this project.

This Run() function here Initializes the MyAnnotationProvider instance.

  • Start OpenRoads Designer from Visual Studio

Since you loaded the OpenRoadsDesigner.exe file if you run the "Start" command.

  • Load your project dll to execute the annotation mechanism

From there, you can load your command like normal using the mdl load key-in. You can then place breakpoints in your source code and debug.

Use below key-in to load and debug the source code:

mdl load ClrSDKExample

Output

Once the ClrSDKExample is loaded into OpenRoads Designer application, it creates a new annotation definition named as "My Alignment Annotation". To view this, follow the below steps:

Open the Annotation Groups from the explorer. Create new or select existing Annotation group, Click Manage.

On Manage click, this will now open the dialog for "Manage Annotations"

Click Add button, this will now show the new Annotation Definition added by the ClrSDK example.